﻿using System;
using System.Linq;
using DataModel.Models;

namespace DataModel.Managers
{
    public class ProfileManager
    {
        readonly UniversityPortalEntities _entityModel;

        public ProfileManager()
        {
            _entityModel = new UniversityPortalEntities();
        }

        public Guid CreateProfile(string description)
        {
            var profile = new Profile {ID = Guid.NewGuid(), description = description};

            _entityModel.AddToProfiles(profile);
            _entityModel.SaveChanges();

            return profile.ID;
        }

        public ProfileModel GetProfile(Guid id)
        {
            Profile profile = _entityModel.Profiles.FirstOrDefault(prfl => prfl.ID == id);
            if (profile != null)
            {
                var profileModel = new ProfileModel {Description = profile.description};
                return profileModel;
            }
            return null;
        }
    }
}
